package com.ssy.lingxi.platform.manage.repository;

import com.ssy.lingxi.platform.manage.entity.base.Unit;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UnitRepository extends JpaRepository<Unit,Long>, JpaSpecificationExecutor<Unit> {

    Page<Unit> findByNameContaining(String name, Pageable page);

    Page<Unit> findByNameContainingAndStatusOrderByIdDesc(String name, Boolean status, Pageable page);

    List<Unit> findByNameAndIdNot(String name, Long id);

    List<Unit> findByEnglishShortNameAndIdNot(String englishShortName, Long id);

    List<Unit> findByName(String name);

    List<Unit> findByEnglishShortName(String englishShortName);

    List<Unit> findByStatus(Boolean status);
}
